package timetracker.client;

import timetracker.client.forms.ContragentForm;
import timetracker.client.forms.ContragentList;
import timetracker.client.forms.TaskForm;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class TimeTracker implements EntryPoint {

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		final Button sendButton = new Button("Add new contragent");
//		final TextBox nameField = new TextBox();
//		nameField.setText("GWT User");
//
		// We can add style names to widgets
		sendButton.addStyleName("sendButton");

		sendButton.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				final ContragentForm dialog = new ContragentForm();
				dialog.center();
				
			}
		});
//		// Add the nameField and sendButton to the RootPanel
//		// Use RootPanel.get() to get the entire body element
		//RootPanel.get("sendButtonContainer").add(new ContragentForm().asWidget());
		RootPanel.get("sendButtonContainer").add(sendButton);

		final Button openContragentsListButton = new Button("Open contragents list");

		openContragentsListButton.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				final ContragentList dialog = new ContragentList();
				dialog.center();
				
			}
		});

		RootPanel.get("sendButtonContainer").add(openContragentsListButton);
		
		final Button openTaskButton = new Button("New task");

		openTaskButton.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				final TaskForm dialog = new TaskForm();
				dialog.center();
				
			}
		});

		RootPanel.get("sendButtonContainer").add(openTaskButton);
		//
//		// Focus the cursor on the name field when the app loads
//		nameField.setFocus(true);
//		nameField.selectAll();


	}
}
